CREATE TABLE crawler_logs (
    id NUMBER PRIMARY KEY,
    action_description VARCHAR2(255),
    website_url VARCHAR2(255),
    start_time TIMESTAMP,
    end_time TIMESTAMP,
    data_table_name VARCHAR2(255)
);
CREATE SEQUENCE crawler_logs_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;

CREATE OR REPLACE TRIGGER crawler_logs_trigger
BEFORE INSERT ON crawler_logs
FOR EACH ROW
BEGIN
    IF :NEW.id IS NULL THEN
        SELECT crawler_logs_seq.NEXTVAL INTO :NEW.id FROM DUAL;
    END IF;
END;
/
----------------------------------------------
CREATE TABLE CHINA_INDEX(
       id NUMBER PRIMARY KEY,
       iName VARCHAR2(20),
       iPrice NUMBER NOT NULL
);
COMMENT ON TABLE CHINESE_INDEX IS '中国指数表';
COMMENT ON COLUMN CHINESE_INDEX.iName IS '指数名';
COMMENT ON COLUMN CHINESE_INDEX.IPRICE IS '最新价';

CREATE SEQUENCE china_index_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;

CREATE OR REPLACE TRIGGER china_index_trigger
BEFORE INSERT ON CHINA_INDEX
FOR EACH ROW
BEGIN
    IF :NEW.id IS NULL THEN
        SELECT china_index_seq.NEXTVAL INTO :NEW.id FROM DUAL;
    END IF;
END;
/
---------------------------------------------------
CREATE TABLE NEW_SHARES_CALENDAR(
       id NUMBER PRIMARY KEY,
       sName VARCHAR2(20),
       sDate DATE
);

COMMENT ON TABLE NEW_SHARES_CALENDAR IS '新股上市日历表';
COMMENT ON COLUMN NEW_SHARES_CALENDAR.SNAME IS '证券简称';
COMMENT ON COLUMN NEW_SHARES_CALENDAR.SDATE IS '上市日期';

CREATE SEQUENCE new_shares_calendar_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;

CREATE OR REPLACE TRIGGER new_shares_calendar_trigger
BEFORE INSERT ON NEW_SHARES_CALENDAR
FOR EACH ROW
BEGIN
    IF :NEW.id IS NULL THEN
        SELECT new_shares_calendar_seq.NEXTVAL INTO :NEW.id FROM DUAL;
    END IF;
END;
/
----------------------------------------------------
CREATE TABLE SECURITIES_ALERTS(
       id NUMBER PRIMARY KEY,
       saTitle VARCHAR2(500),
       saTime VARCHAR2(10)
       status NUMBER
);
COMMENT ON TABLE SECURITIES_ALERTS IS '证券快讯表';
COMMENT ON COLUMN SECURITIES_ALERTS.SATITLE IS '快讯内容';
COMMENT ON COLUMN SECURITIES_ALERTS.SATIME IS '快讯时间';

CREATE SEQUENCE securities_alerts_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;

CREATE OR REPLACE TRIGGER csecurities_alerts_trigger
BEFORE INSERT ON SECURITIES_ALERTS
FOR EACH ROW
BEGIN
    IF :NEW.id IS NULL THEN
        SELECT securities_alerts_seq.NEXTVAL INTO :NEW.id FROM DUAL;
    END IF;
END;
/
------------------------------------------------------
CREATE TABLE STOCK_CONNECT_FUND_FLOWS(
       id NUMBER PRIMARY KEY,
       scffName VARCHAR2(20),
       scffBalance VARCHAR2(20),
       scffUsed VARCHAR2(20),
       scffNetPurchases VARCHAR2(20)
);
COMMENT ON TABLE STOCK_CONNECT_FUND_FLOWS IS '沪深港通资金流';
COMMENT ON COLUMN STOCK_CONNECT_FUND_FLOWS.SCFFNAME IS '板块名称';
COMMENT ON COLUMN STOCK_CONNECT_FUND_FLOWS.SCFFBALANCE IS '资金余额';
COMMENT ON COLUMN STOCK_CONNECT_FUND_FLOWS.SCFFNETPURCHASES IS '成交净买额';

CREATE SEQUENCE stock_connect_fund_flows_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;

CREATE OR REPLACE TRIGGER stock_connect_fund_flows_trigger
BEFORE INSERT ON STOCK_CONNECT_FUND_FLOWS
FOR EACH ROW
BEGIN
    IF :NEW.id IS NULL THEN
        SELECT stock_connect_fund_flows_seq.NEXTVAL INTO :NEW.id FROM DUAL;
    END IF;
END;
/
-----------------------------------------------------
CREATE TABLE SECTOR_CAPITAL_FLOWS(
       id NUMBER  PRIMARY KEY,
       scfName VARCHAR2(20),
       scfFlows VARCHAR2(20)
);

COMMENT ON TABLE SECTOR_CAPITAL_FLOWS IS '板块资金流';
COMMENT ON COLUMN SECTOR_CAPITAL_FLOWS.SCFNAME IS '板块名称';
COMMENT ON COLUMN SECTOR_CAPITAL_FLOWS.SCFPRICE IS '涨跌幅';

CREATE SEQUENCE sector_capital_flows_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;

CREATE OR REPLACE TRIGGER sector_capital_flows_trigger
BEFORE INSERT ON SECTOR_CAPITAL_FLOWS
FOR EACH ROW
BEGIN
    IF :NEW.id IS NULL THEN
        SELECT sector_capital_flows_seq.NEXTVAL INTO :NEW.id FROM DUAL;
    END IF;
END;
/
